import http from '@/utils/request.js'

/***** 后台管理 分类(Category) 模块 *******/
const prefix = "admin/v1/category/"

// 一级分类列表数据(数据量不多，就不作分页处理了)
export function getList() {
  return http.request({
    url: prefix + "list",
    method: "get",
  });
}

//删除分类ById
export function deleteById(id) {
  return http.request({
    url: prefix + id,
    method: "delete",
  });
}

//保存  更新/增加分类 （id有则更新，无则增加）
export function save(params) {
  let {id, name, sort, img} = params;
  let url = null;

  if (id) {
    url = prefix + "update";
  } else {
    url = prefix + "insert";
  }

  return http.request({
    url: url,
    method: "post",
    data: params,
  });
}

//查询分类详情ById
export function getDetailById(id) {
  return http.request({
    url: prefix + id,
    method: "get",
  });
}

